# Contributor: Fabio Ribeiro <fabiorphp@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php84-pecl-memcached
_extname=memcached
pkgver=3.3.0
_pkgver=${pkgver/_rc/RC}
pkgrel=0
pkgdesc="PHP 8.4 extension for interfacing with memcached via libmemcached library - PECL"
url="https://pecl.php.net/package/memcached"
arch="all"
license="PHP-3.01"
_phpv=84
_php=php$_phpv
depends="$_php-session $_php-pecl-igbinary $_php-pecl-msgpack"
makedepends="$_php-dev zlib-dev libmemcached-dev cyrus-sasl-dev libevent-dev zstd-dev"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$_pkgver.tgz"
builddir="$srcdir/$_extname-$_pkgver"

install_if="php-$_extname php$_phpv"

build() {
	phpize$_phpv
	./configure \
		--prefix=/usr \
		--with-php-config=php-config$_phpv \
		--with-zstd \
		--enable-memcached-json \
		--enable-memcached-igbinary \
		--enable-memcached-msgpack \
		--enable-memcached-protocol \
		--enable-memcached-sasl
	make
}

check() {
	# Tests require memcached server, basic check
	$_php -d extension="$builddir"/modules/$_extname.so --ri $_extname
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	local _confdir="$pkgdir"/etc/$_php/conf.d
	mkdir -p $_confdir
	echo "extension=$_extname" > $_confdir/20_$_extname.ini
}

sha512sums="
bdbe8b203cadcda50c4f8099fac1161424f3091537027251aaba7d9ba9a7932f59a9ac201dca9d9ae3aa59ff833ac6aa0284c5ab118cdb85a9fd89f63a95509a  php-pecl-memcached-3.3.0.tgz
"
